package com.teacold.customdemo;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;

import com.teacold.customdemo.chapter_thirteen.GestureActivity;
import com.teacold.customdemo.chapter_three.PathAnimator;
import com.beicai.tfndk.TFCommon;
import com.teacold.jnidemo.JNITools;
import com.teacold.utils.toast.ToastTool;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener, View.OnTouchListener {
    private Button jump_animation, jump_player;
    private String TAG = this.getClass().getName();
    private Button normal_toast, image_toast, time_toast;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.e(TAG, "onCreate");
        setContentView(R.layout.activity_main);
        initView();
        initMonitor();
    }

    private void initView() {
        jump_animation = findViewById(R.id.jump_animation);
        jump_player = findViewById(R.id.jump_player);
        normal_toast = findViewById(R.id.normal_toast);
        image_toast = findViewById(R.id.image_toast);
        time_toast = findViewById(R.id.time_toast);
        jump_player.setText(JNITools.getKey());
        time_toast.setText(TFCommon.getAESKey());

    }

    private void initMonitor() {
        jump_animation.setOnClickListener(this);
        jump_player.setOnClickListener(this);
        jump_player.setOnTouchListener(this);
        normal_toast.setOnClickListener(this);
        image_toast.setOnClickListener(this);
        time_toast.setOnClickListener(this);


    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.jump_animation:
                startActivity(new Intent(this, PathAnimator.class));
                break;
            case R.id.jump_player:
//                NetPay.smallProgramPay(this,"http://192.168.1.88:97/appPay/miniProgramParam.mvc",path);
                startActivity(new Intent(this,GestureActivity.class));
//                Log.e("ssssss加密小程序key", EcpssRSAUtil.encryption("wx625a5eb822761543"));
//                Log.e("ssssss解密小程序key：", EcpssRSAUtil.decrypt(EcpssRSAUtil.encryption("wx625a5eb822761543")));
//                Log.e("ssssss加密小程序id：", EcpssRSAUtil.encryption("gh_4bafd7015f04"));
//                Log.e("ssssss解密小程序id：", EcpssRSAUtil.decrypt(EcpssRSAUtil.encryption("gh_4bafd7015f04")));
////              Log.e("ssssss解密文字2222：",EcpssRSAUtil.decrypt(EcpssRSAUtil.encryption2("汇潮支付")));
//                Log.e("ssssss解密文字2222：", EcpssRSAUtil.decrypt(EcpssRSAUtil.encryption("汇潮支付")));
//                Log.e("ssssss解密文字：", EcpssRSAUtil.decrypt("JR1kJxXwdq/NEmcITMqGUNe/ZbPHHYUKMlHRK5WjxN43wGYu4Vse7ja6DJ433H3NMoKbXVVFJzyP2B2MzyzD0w2uWD9faruhwKpp2NqoxMeJqo+ovRqhXRXSBk2jfBAl4R4KQ+XffetRJzGRTjetfzPT3Vvy1D3uakfTEob8BwE="));
                break;
            case R.id.normal_toast:
                ToastTool.ToastTool(this, "我是普通的Toast");
                break;
            case R.id.image_toast:
                ToastTool.ToastTool(this, "我是带图片的Toast", R.mipmap.sixin);
                break;
            case R.id.time_toast:
                ToastTool.ToastTool(this, "我是带图片的Toast", R.mipmap.sixin, 12000L);
                break;


        }
    }

    //Activity的onTounch事件
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        Log.e(TAG, "onTouch");
        switch (event.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_DOWN:
                Log.e(TAG, "MainActivity onTouch ACTION_DOWN");
                break;
            case MotionEvent.ACTION_MOVE:
                Log.e(TAG, "MainActivity onTouch ACTION_MOVE");
                break;
            case MotionEvent.ACTION_CANCEL:
                Log.e(TAG, "MainActivity onTouch ACTION_CANCEL");
                break;
            case MotionEvent.ACTION_UP:
                Log.e(TAG, "MainActivity onTouch ACTION_UP");
                break;
            default:
                Log.e(TAG, "MainActivity onTouchEvent " + event.getAction());
                break;
        }
        return false;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        Log.e(TAG, "dispatchTouchEvent");
        return super.dispatchTouchEvent(ev);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.e(TAG, "onTouchEvent");
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                Log.e(TAG, "MainActivity onTouchEvent ACTION_DOWN");
                break;
            case MotionEvent.ACTION_MOVE:
                Log.e(TAG, "MainActivity onTouchEvent ACTION_MOVE");
                break;
            case MotionEvent.ACTION_CANCEL:
                Log.e(TAG, "MainActivity onTouchEvent ACTION_CANCEL");
                break;
            case MotionEvent.ACTION_UP:
                Log.e(TAG, "MainActivity onTouchEvent ACTION_UP");
                break;
            default:
                Log.e(TAG, "MainActivity onTouchEvent " + event.getAction());
                break;
        }
        return super.onTouchEvent(event);
    }
}
